c = 53**123+65**2222-172**12
v=''
count=0

while c>0:
    v=str(c%7)+v
    c=c//7
for i in ('12345'):
    v=v.replace(i,'#')
print(v.count('6#'),v)

'''
while c>0:
    if c%7 in (1,2,3,4,5) and (c//7)%7==6:
        count+=1
    c=c//7
print(count)
'''
